import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-07-24
 * Time: 23:22
 */
class Solution15 {
    public int findContentChildren(int[] g, int[] s) {
        int n = g.length, m = s.length,ret = 0;

        //大前提：排序
        Arrays.sort(g);
        Arrays.sort(s);

        for(int i = 0, j = 0; i < n && j < m; i++,j++) {
            while(j < m && s[j] < g[i]) {
                //一直找满足条件的
                j++;
            }
            if(j < m) {
                ret++;
            }
        }
        return ret;
    }
}
